const mongoose = require('mongoose')

const Schema = mongoose.Schema

const UserSchema = new Schema(
  {
    username: {
      type: String,
      require: true,
      unique: true,
    },
    password: {
      type: String,
      require: true,
    },
    full_name: {
      type: String,
    },
    address: {
      type: String,
    },
    phone: {
      type: Number,
    },
    sex: {
      type: Number,
      default: 1,
    },
    age: {
      type: Number,
    },
    idCard: {
      type: Number,
    },
    role: {
      type: Schema.Types.ObjectId,
      ref: 'Role',
    },
  },
  {
    timestamps: { currentTime: () => Date.now() },
  }
)

const UserModel = mongoose.model('User', UserSchema)

module.exports = UserModel
